home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
boe.pres.k12.wv.us
/
boe.pres.k12.wv.us.zip
/
boe.pres.k12.wv.us
/
Utilities
/
Xerox Workcentre 5335
/
Windows Scan
/
64-bit_x64
/
Russian
/
cpsimage.cab
/
data
/
xipScripts
/
hlDemo.elf
next >
Wrap
Text File
|
2009-04-23
|
3KB
|
103 lines
/*
** This script demonstrates XIPS highlighted text extraction. It reads
** image files from a specified input directory. For each image file, it
** extracts the highlighted text regions into separate images, and then writes
** these text extraction images to a specified output directory.
*/
// Load scripted support procedures
#load "xipProcs/hlExtract.proc";
// Imported parameters
IMPORT STRING inpath = ".";
IMPORT STRING outpath = ".";
IMPORT STRING pattern = "*.*";
IMPORT ELFBOOLEAN display = 1;
IMPORT ELFBOOLEAN save = 0;
XIPIMAGE imgIn, imgOut;
ELFLIST output;
STRING infileList;
STRING infile;
STRING outfile;
STRING label;
INTEGER nOutputs;
INTEGER done;
INTEGER i;
print "XIPS Highlighted Text Extraction Demo";
// Register image processing classes
LoadClasses (filename: "xeng");
// Check for invalid input file path
if (!IsDir (filename: inpath)) {
print "ERROR: Input file path does not exist";
return;
}
print " Input file path: " + inpath;
// Check for invalid output file path
if (!IsDir (filename: outpath)) {
print "ERROR: Output file path does not exist";
return;
}
print " Output file path: " + outpath;
// Append slash to input file path if necessary
if (inpath.index (val: inpath.length () - 1) != "/")
inpath = inpath + "/";
// Append slash to output file path if necessary
if (outpath.index (val: outpath.length () - 1) != "/")
outpath = outpath + "/";
// Get list of files from input file path
infileList = System (cmd: "ls " + inpath + pattern, mode: "r");
print " Input file pattern: " + pattern;
// Process each file in input files list
for (done=0; !done;) {
// Get next input filename
infile = infileList.getLine ();
if (!infile) {
done = 1;
} else {
// Read input image
imgIn = readimage (filename: infile).exec ();
print " Processing " + infile + "...";
// Extract highlighted text regions from input image
output = XIPHighlightExtract (input: imgIn);
// Report number of text extraction images
nOutputs = output.length ();
print " Number of text extraction images: " + nOutputs;
// No text extraction images, process next input image
if (nOutputs == 0)
continue;
// Process each text extraction image
for (i=0; i<nOutputs; i++) {
imgOut = output[i];
// Display and/or save text extraction image
if (display || save) {
label = imgOut.info;
label.getToken ();
outfile = infile.name () + "_text_" + i + "_"
+ label.getToken () + "." + infile.ext ();
if (display)
imgOut.display (title: outfile);
if (save)
imgOut.writeint (filename: outpath + outfile);
}
}
}
}